package com.javastudy.autowiredStudy.factorybeanstudy;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Service;

/**
 * 获取factoryBean
 * @author mac
 * @date 2021/9/7 2:47 下午
 */
public class MyFactoryBeanClass implements BeanFactoryAware {
    public static void main(String[] args) {

    }
    private static BeanFactory beanFactory;
    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        MyFactoryBeanClass.beanFactory = beanFactory;
    }


    public static void getFactoryBean(){
        //获取的是实现了factorybean的getObject()的返回值
        Object myFactoryBean = beanFactory.getBean("myFactoryBean");
        //获取的是实现了factorybean的对象
        Object bean = beanFactory.getBean("&myFactoryBean");
    }


}

